<?php

$CHEAT_SITE = array(
    "chpoken.com" => array("http://himc.com" => 1),
    "secret.loc" => array("http://adcheat.loc" => 1)
);

$PAGES = array(
    "http://adcheat.loc" => array("/", "/sample-page/"),
    "http://himc.com" => array("/", "/press.html", "/financials.html", "/contact.html", "/management.html", "/about.html")
);

$OPTIONS = array(
    "himc.com" => array(
        "CHEAT" => "tgp",
    	"SECRET_SITE" => "http://chpoken.com",
        "KEYWORDS" => "himc_aligned",
        "ADSENSE_ID" => "test",
        "SAMPLE" => "cse",
        "TEST" => true
    ),

    "adcheat.loc" => array(
        "CHEAT" => "cams",
    	"SECRET_SITE" => "http://secret.loc",
        "KEYWORDS" => "himc_aligned",
        "ADSENSE_ID" => "test",
        "SAMPLE" => "cse",
        "TEST" => true
    )
);

function getOptionHost($name) {
    global $OPTIONS;    
    if (!isset($OPTIONS[$_SERVER["HTTP_HOST"]])) {
        echo "Config for site ".$_SERVER["HTTP_HOST"]." does not exist";
        exit;
    }
    $siteOptions = $OPTIONS[$_SERVER["HTTP_HOST"]];
    if (!isset($siteOptions[$name])) {
        echo "Option ".$name." for site ".$_SERVER["HTTP_HOST"]." does not exist";
        exit;
    }
    return $siteOptions[$name];
}

function getOption($name) {
    $url = parse_url($_SERVER['HTTP_REFERER']);
    $site = $url["host"];

    global $OPTIONS;    
    if (!isset($OPTIONS[$site])) {
        echo "Config for site ".$site." does not exist";
        exit;
    }
    $siteOptions = $OPTIONS[$site];
    if (!isset($siteOptions[$name])) {
        echo "Option ".$name." for site ".$site." does not exist";
        exit;
    }
    return $siteOptions[$name];
}

?>
